<template>
  <div class="route-test">
    <div class="test-container">
      <h1>路由测试页面</h1>
      <p>测试所有配置的路由是否正常工作</p>
      
      <div class="route-list">
        <h2>可用路由：</h2>
        <div class="route-grid">
          <div 
            v-for="route in testRoutes" 
            :key="route.path"
            class="route-card"
          >
            <div class="route-info">
              <h3>{{ route.name }}</h3>
              <p class="route-path">{{ route.path }}</p>
              <p class="route-desc">{{ route.description }}</p>
            </div>
            
            <div class="route-actions">
              <router-link :to="route.path" class="test-btn">
                访问页面
              </router-link>
              <button @click="testRoute(route.path)" class="test-btn secondary">
                编程式跳转
              </button>
            </div>
          </div>
        </div>
      </div>
      
      <div class="current-route">
        <h2>当前路由信息：</h2>
        <div class="route-details">
          <p><strong>路径：</strong>{{ $route.path }}</p>
          <p><strong>名称：</strong>{{ $route.name }}</p>
          <p><strong>参数：</strong>{{ JSON.stringify($route.params) }}</p>
          <p><strong>查询：</strong>{{ JSON.stringify($route.query) }}</p>
          <p><strong>元信息：</strong>{{ JSON.stringify($route.meta) }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'RouteTest',
  data() {
    return {
      testRoutes: [
        {
          path: '/',
          name: '首页',
          description: '根路径，会重定向到监控平台'
        },
        {
          path: '/monitoring',
          name: '监控平台',
          description: '智能瓷砖监控平台主页面'
        },
        {
          path: '/monitoring/realtime',
          name: '实时数据',
          description: '实时数据监控页面'
        },
        {
          path: '/monitoring/history',
          name: '历史数据',
          description: '历史数据分析页面'
        },
        {
          path: '/monitoring/trend',
          name: '趋势分析',
          description: '数据趋势分析页面'
        },
        {
          path: '/monitoring/heatmap',
          name: '压力热图',
          description: '瓷砖压力分布热图页面'
        },
        {
          path: '/smart-monitoring',
          name: '智能瓷砖监控平台',
          description: '基于 miaoduo 设计的智能瓷砖监控平台'
        },
        {
          path: '/smart-monitoring/overview',
          name: '系统概况',
          description: '智能瓷砖监控 - 系统概况'
        },
        {
          path: '/smart-monitoring/realtime-status',
          name: '实时状态',
          description: '智能瓷砖监控 - 实时状态'
        },
        {
          path: '/smart-monitoring/anomaly-stats',
          name: '异常统计',
          description: '智能瓷砖监控 - 异常统计'
        },
        {
          path: '/smart-monitoring/history',
          name: '历史回溯',
          description: '智能瓷砖监控 - 历史回溯'
        },
        {
          path: '/smart-monitoring/data-monitoring',
          name: '数据监控',
          description: '智能瓷砖监控 - 数据监控'
        },
        {
          path: '/smart-monitoring/alert-management',
          name: '报警管理',
          description: '智能瓷砖监控 - 报警管理'
        },
        {
          path: '/smart-monitoring/system-settings',
          name: '系统设置',
          description: '智能瓷砖监控 - 系统设置'
        },
        {
          path: '/nonexistent',
          name: '404测试',
          description: '测试404页面（不存在的路径）'
        }
      ]
    }
  },
  methods: {
    testRoute(path) {
      this.$router.push(path)
    }
  }
}
</script>

<style scoped>
.route-test {
  min-height: 100vh;
  background: #f5f5f5;
  padding: 40px 20px;
}

.test-container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

h1 {
  color: #1677FF;
  text-align: center;
  margin-bottom: 16px;
  font-size: 32px;
}

.route-list {
  margin: 40px 0;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.route-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  background: #fafafa;
  transition: all 0.3s ease;
}

.route-card:hover {
  border-color: #1677FF;
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.1);
}

.route-info h3 {
  color: #1677FF;
  margin-bottom: 8px;
  font-size: 18px;
}

.route-path {
  font-family: 'Monaco', 'Consolas', monospace;
  background: #f0f0f0;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.route-desc {
  color: #666;
  font-size: 14px;
  margin-bottom: 16px;
}

.route-actions {
  display: flex;
  gap: 12px;
}

.test-btn {
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
}

.test-btn:not(.secondary) {
  background: #1677FF;
  color: white;
}

.test-btn:not(.secondary):hover {
  background: #0958d9;
}

.test-btn.secondary {
  background: white;
  color: #1677FF;
  border: 1px solid #1677FF;
}

.test-btn.secondary:hover {
  background: #f0f7ff;
}

.current-route {
  margin-top: 40px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #1677FF;
}

.route-details {
  margin-top: 16px;
}

.route-details p {
  margin: 8px 0;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 14px;
}

.route-details strong {
  color: #1677FF;
}

@media (max-width: 768px) {
  .test-container {
    padding: 20px;
  }
  
  .route-grid {
    grid-template-columns: 1fr;
  }
  
  .route-actions {
    flex-direction: column;
  }
}
</style>
